<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>tab栏切换</title>
    <style>
      li {
        list-style-type: none;
      }
      .tab ul li {
        float: left;
        padding: 0 5px;
      }
      .current {
        background-color: #ff8500;
      }
      .item {
        display: none;
      }
      .clearfix:before,
      .clearfix:after {
        content: "";
        display: table;
      }
      .clearfix:after {
        clear: both;
      }
      .clearfix {
        *zoom: 1;
      }
    </style>
  </head>
  <body>
    <div class="tab clearfix">
      <ul>
        <li class="current">商品介绍</li>
        <li>规格与包装</li>
        <li>售后保障</li>
        <li>商品评价</li>
        <li>手机社区</li>
      </ul>
    </div>
    <div class="tab_con">
      <div class="item" style="display: block">商品介绍模块内容</div>
      <div class="item">规格与包装模块内容</div>
      <div class="item">售后保障模块内容</div>
      <div class="item">商品介绍模块内容</div>
      <div class="item">手机社区模块内容</div>
    </div>
    <script>
      var lis = document.querySelectorAll("li");
      var divs = document.querySelectorAll(".item");
      for (var i = 0; i < lis.length; i++) {
        lis[i].setAttribute("index", i);
        lis[i].onclick = function () {
          for (var i = 0; i < lis.length; i++) {
            lis[i].className = "";
            divs[i].style.display = "none";
          }
          this.className = "current";
          divs[this.getAttribute("index")].style.display = "block";
        };
      }
    </script>
  </body>
</html>
